package dp.pra.concurrent;

/***
 * 线程中内存重排序演示
 */
public class PossibleRecording {
    static int x=0,y=0;
    static int a=0,b=0;


    public static void main(String[] args) throws InterruptedException {
        Thread one = new Thread(new Runnable() {
            @Override
            public void run() {
                a=1;
                x=b;
            }
        });
        Thread other = new Thread(new Runnable() {
            @Override
            public void run() {
                b=1;
                y=a;
            }
        });
        one.start();
        other.start();
        one.join();
        other.join();
        System.out.println("( "+x+", "+y+" )");
    }

}
